<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class House.
 * @property int id
 * @property int houser_user_id
 * @property int lease_mode
 * @property int check_status
 * @property string check_message
 */
class House extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $guarded = [];

    protected $casts = [
        'created_at' => 'date:Y-m-d H:i:s',
        'updated_at' => 'date:Y-m-d H:i:s',
    ];

    public function houseUserBind()
    {
        return $this->hasMany(HouseUserBind::class);
    }

    public function tenants()
    {
        return $this->hasMany(HouseUserBind::class);
    }

    public function userScore()
    {
        return $this->hasMany(HouserScore::class);
    }

    public function getImagesAttribute($value)
    {
        return formatImageUrls($value);
    }

    public function houser()
    {
        return $this->belongsTo(UserProfile::class, 'houser_user_id', 'user_id');
    }
}
